package cn.quevo.core.file.draw.impl;

import cn.quevo.core.exception.CustomException;
import cn.quevo.core.file.draw.AbstractCodeDraw;
import cn.quevo.core.file.entity.WriteImage;

import java.awt.*;
import java.util.Random;

/**
 * 噪点干扰
 *
 * @author July july_sky@foxmail.com
 * @date 2018/07/24 16:55:55
 * @Copyright 东方浩星（北京）传媒科技有限公司版权所有.All Rights Reserved.
 * @version 1.0
 */
public class NoiseDraw extends AbstractCodeDraw {
    @Override
    protected void checked(Graphics2D gd, WriteImage writeImage) throws CustomException {
        Random random = new Random();
        for (int i = 0; i < writeImage.getInterLine(); i++) {
            gd.setColor(new Color(random.nextInt(255 + 1), random.nextInt(255 + 1), random.nextInt(255 + 1)));
            gd.drawOval(random.nextInt(writeImage.getWidth()), random.nextInt(writeImage.getHeight()), 1, 1);
        }
    }
}
